/**
 * @file abstract_mapping.cc
 * @author DustinKsi (dustinksi@126.com)
 * @brief
 * @version 0.1
 * @date 2019-12-11
 *
 * @copyright Copyright (c) 2019
 *
 */

#include "venus/mapping/interface/abstract_mapping.h"

namespace VEnus {
namespace Mapping {

void AbstractMapping::SetMappingOptions(const MappingOptions &options) {
  _options = options;
  if(options.load_map())
  {
    LoadExistMapFile();
  }
}

void AbstractMapping::SaveMap()
{
  D_INFO << BASHB << "write current map to: " << BASHW<< _options.map_filename();
  
  VEnus::Sensor::Feature2DList feature_list = current_graph.feature_list();
  std::string map_filename = _options.map_filename();
  VEnus::Sensor::feature_map_saver(feature_list, map_filename);
}

bool AbstractMapping::LoadExistMapFile()
{
  D_INFO << BASHB << "load map from: " << BASHW<< _options.map_filename();
  static VEnus::Sensor::Feature2DList feature_list;
  std::string map_filename = _options.map_filename();
  VEnus::Sensor::feature_map_loader(map_filename, current_graph.mutable_feature_list());

  return true;
}

}
}